- EnumerableM <A> (IEnumerable<A> runEnumerable)
- Empty
- EnumerableM (ReadOnlySpan<A> ma)
- Count ()
- Concat (IEnumerable<A> items)
- Concat (EnumerableM<A> items)
- AsEnumerable ()
- Iter (Action<A> f)
- Iter (Action<A, int> f)
- Traverse <F, B> (Func<A, K<F, B>> f)
- Map <B> (Func<A, B> f)
- Map <B> (Func<A, int, B> f)
- Select <B> (Func<A, B> f)
- Select <B> (Func<A, int, B> f)
- Bind <B> (Func<A, EnumerableM<B>> f)
- Bind <B> (Func<A, K<EnumerableM, B>> f)
- SelectMany <B> (Func<A, EnumerableM<B>> bind)
- SelectMany <B, C> (Func<A, EnumerableM<B>> bind, Func<A, B, C> project)
- SelectMany <B> (Func<A, IEnumerable<B>> bind)
- SelectMany <B, C> (Func<A, IEnumerable<B>> bind, Func<A, B, C> project)
- Filter (Func<A, bool> f)
- Where (Func<A, bool> f)
- Any ()
- Intersperse (A value)
- GetHashCode ()
- CompareTo (object? obj)
- ToString ()
- ToFullString (string separator = ", ")
- ToFullArrayString (string separator = ", ")
- Combine (EnumerableM<A> y)
- + (EnumerableM<A> x, EnumerableM<A> y)
- > (EnumerableM<A> x, EnumerableM<A> y)
- >= (EnumerableM<A> x, EnumerableM<A> y)
- < (EnumerableM<A> x, EnumerableM<A> y)
- <= (EnumerableM<A> x, EnumerableM<A> y)
- Equals <EqA> (EnumerableM<A> rhs)
- Equals (EnumerableM<A>? other)
- Skip (int amount)
- Take (int amount)
- TakeWhile (Func<A, bool> pred)
- TakeWhile (Func<A, int, bool> pred)
- Partition (Func<A, bool> predicate)
- CompareTo <OrdA> (EnumerableM<A> rhs)
- GetEnumerator ()
- Cast <B> ()
- Zip <B> (IEnumerable<B> rhs)
- Zip <B, C> (IEnumerable<B> rhs, Func<A, B, C> zipper)
- AdditiveIdentity
- EnumerableMExtensions
- As <A> (this K<EnumerableM, A> xs)
- AsEnumerableM <A> (this IEnumerable<A> xs)
- Flatten <A> (this EnumerableM<EnumerableM<A>> ma)
- Choose <A, B> (this EnumerableM<A> list, Func<A, Option<B>> selector)
- Rev <T> (this EnumerableM<T> list)
- EnumerableM
- flatten <A> (EnumerableM<EnumerableM<A>> ma)
- empty <A> ()
- singleton <A> (A value)
- create <A> ()
- create <A> (params A[] items)
- createRange <A> (ReadOnlySpan<A> items)
- createRange <A> (IEnumerable<A> items)
- generate <A> (int count, Func<int, A> generator)
- repeat <A> (A item, int count)
- head <A> (EnumerableM<A> list)
- choose <A, B> (EnumerableM<A> list, Func<A, Option<B>> selector)
- rev <T> (EnumerableM<T> list)
- scan <S, T> (EnumerableM<T> list, S state, Func<S, T, S> folder)
- scanBack <S, T> (EnumerableM<T> list, S state, Func<S, T, S> folder)
- zip <T, U, V> (EnumerableM<T> list, EnumerableM<U> other, Func<T, U, V> zipper)
- zip <T, U> (EnumerableM<T> list, EnumerableM<U> other)
- distinct <T> (EnumerableM<T> list)
- distinct <EQ, T> (EnumerableM<T> list)
- distinct <T, K> (EnumerableM<T> list, Func<T, K> keySelector, Option<Func<K, K, bool>> compare = default)
- take <T> (EnumerableM<T> list, int count)
- takeWhile <T> (EnumerableM<T> list, Func<T, bool> pred)
- takeWhile <T> (EnumerableM<T> list, Func<T, int, bool> pred)
- span <T> (EnumerableM<T> self, Func<T, bool> pred)
- EnumerableM
record EnumerableM <A> (IEnumerable<A> runEnumerable) Source #
Lazy sequence
This is a lightweight wrapper around IEnumerable
that also implements traits
that make it play nice with other types in this library: Monad, Traversable, etc.
type | A | Type of the values in the sequence |
property EnumerableM<A> AdditiveIdentity Source #
constructor EnumerableM (ReadOnlySpan<A> ma) Source #
Constructor from lazy sequence
method EnumerableM<A> Concat (IEnumerable<A> items) Source #
Add a range of items to the end of the sequence
Forces evaluation of the entire lazy sequence so the items can be appended.
method EnumerableM<A> Concat (EnumerableM<A> items) Source #
Add a range of items to the end of the sequence
Forces evaluation of the entire lazy sequence so the items can be appended.
method IEnumerable<A> AsEnumerable () Source #
Stream as an enumerable
method Unit Iter (Action<A> f) Source #
Impure iteration of the bound values in the structure
returns | Returns the original unmodified structure |
method Unit Iter (Action<A, int> f) Source #
Impure iteration of the bound values in the structure
returns | Returns the original unmodified structure |
method K<F, EnumerableM<B>> Traverse <F, B> (Func<A, K<F, B>> f) Source #
Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.
type | F | Applicative functor trait |
type | B | Bound value (output) |
param | f | |
param | ta | Traversable structure |
method EnumerableM<B> Map <B> (Func<A, B> f) Source #
Map the sequence using the function provided
type | B | |
param | f | Mapping function |
returns | Mapped sequence |
method EnumerableM<B> Map <B> (Func<A, int, B> f) Source #
Map the sequence using the function provided
type | B | |
param | f | Mapping function |
returns | Mapped sequence |
method EnumerableM<B> Select <B> (Func<A, B> f) Source #
Map the sequence using the function provided
type | B | |
param | f | Mapping function |
returns | Mapped sequence |
method EnumerableM<B> Select <B> (Func<A, int, B> f) Source #
Map the sequence using the function provided
type | B | |
param | f | Mapping function |
returns | Mapped sequence |
method EnumerableM<B> Bind <B> (Func<A, EnumerableM<B>> f) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | f | Bind function |
returns | Flat-mapped sequence |
method EnumerableM<B> Bind <B> (Func<A, K<EnumerableM, B>> f) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | f | Bind function |
returns | Flat-mapped sequence |
method EnumerableM<B> SelectMany <B> (Func<A, EnumerableM<B>> bind) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | bind | Bind function |
returns | Flat-mapped sequence |
method EnumerableM<C> SelectMany <B, C> (Func<A, EnumerableM<B>> bind, Func<A, B, C> project) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | bind | Bind function |
returns | Flat-mapped sequence |
method EnumerableM<B> SelectMany <B> (Func<A, IEnumerable<B>> bind) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | bind | Bind function |
returns | Flat-mapped sequence |
method EnumerableM<C> SelectMany <B, C> (Func<A, IEnumerable<B>> bind, Func<A, B, C> project) Source #
Monadic bind (flatmap) of the sequence
type | B | Bound return value type |
param | bind | Bind function |
returns | Flat-mapped sequence |
method EnumerableM<A> Filter (Func<A, bool> f) Source #
Filter the items in the sequence
param | f | Predicate to apply to the items |
returns | Filtered sequence |
method EnumerableM<A> Where (Func<A, bool> f) Source #
Filter the items in the sequence
param | f | Predicate to apply to the items |
returns | Filtered sequence |
Returns true if the sequence has items in it
returns | True if the sequence has items in it |
method EnumerableM<A> Intersperse (A value) Source #
Inject a value in between each item in the sequence
type | A | Bound type |
param | ma | Sequence to inject values into |
param | value | Item to inject |
returns | A sequence with the values injected |
method int GetHashCode () Source #
Get the hash code for all of the items in the sequence, or 0 if empty
returns |
method string ToString () Source #
Format the collection as [a, b, c, ...]
The ellipsis is used for collections over 50 items
To get a formatted string with all the items, use ToFullString
or ToFullArrayString
.
method string ToFullString (string separator = ", ") Source #
Format the collection as a, b, c, ...
method string ToFullArrayString (string separator = ", ") Source #
Format the collection as [a, b, c, ...]
method EnumerableM<A> TakeWhile (Func<A, bool> pred) Source #
Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't
returns | A new sequence with the first items that match the predicate |
method EnumerableM<A> TakeWhile (Func<A, int, bool> pred) Source #
Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't. An index value is also provided to the predicate function.
returns | A new sequence with the first items that match the predicate |
method (EnumerableM<A> First, EnumerableM<A> Second) Partition (Func<A, bool> predicate) Source #
Partition a list into two based on a predicate
param | predicate | True if the item goes in the first list, false for the second list |
returns | Pair of lists |
method int CompareTo <OrdA> (EnumerableM<A> rhs) Source #
Compare to another sequence
method IEnumerator<A> GetEnumerator () Source #
class EnumerableMExtensions Source #
method EnumerableM<A> AsEnumerableM <A> (this IEnumerable<A> xs) Source #
method EnumerableM<B> Choose <A, B> (this EnumerableM<A> list, Func<A, Option<B>> selector) Source #
Applies the given function 'selector' to each element of the sequence. Returns the sequence comprised of the results for each element where the function returns Some(f(x)).
type | A | sequence item type |
param | list | sequence |
param | selector | Selector function |
returns | Mapped and filtered sequence |
class EnumerableM Source #
Cons sequence module Represents a sequence of values in a similar way to IEnumerable, but without the issues of multiple evaluation for key LINQ operators like Skip, Count, etc.
type | A | Type of the values in the sequence |
method EnumerableM<A> create <A> (params A[] items) Source #
Create a sequence from a initial set of items
param | items | Items |
returns | sequence |
method EnumerableM<A> createRange <A> (ReadOnlySpan<A> items) Source #
Create a sequence from an initial set of items
param | items | Items |
returns | sequence |
method EnumerableM<A> createRange <A> (IEnumerable<A> items) Source #
Create a sequence from an initial set of items
param | items | Items |
returns | sequence |
method EnumerableM<A> generate <A> (int count, Func<int, A> generator) Source #
Generates a sequence of A using the provided delegate to initialise each item.
method EnumerableM<A> repeat <A> (A item, int count) Source #
Generates a sequence that contains one repeated value.
method Option<A> head <A> (EnumerableM<A> list) Source #
Get the item at the head (first) of the sequence or None if the sequence is empty
param | list | sequence |
returns | Optional head item |
method EnumerableM<B> choose <A, B> (EnumerableM<A> list, Func<A, Option<B>> selector) Source #
Applies the given function 'selector' to each element of the sequence. Returns the sequence comprised of the results for each element where the function returns Some(f(x)).
type | A | sequence item type |
param | list | sequence |
param | selector | Selector function |
returns | Mapped and filtered sequence |
method EnumerableM<T> rev <T> (EnumerableM<T> list) Source #
Reverses the sequence (Reverse in LINQ)
type | T | sequence item type |
param | list | sequence to reverse |
returns | Reversed sequence |
method EnumerableM<S> scan <S, T> (EnumerableM<T> list, S state, Func<S, T, S> folder) Source #
Applies a function to each element of the sequence, threading an accumulator argument through the computation. This function takes the state argument, and applies the function to it and the first element of the sequence. Then, it passes this result into the function along with the second element, and so on. Finally, it returns the list of intermediate results and the final result.
type | S | State type |
type | T | sequence item type |
param | list | sequence to fold |
param | state | Initial state |
param | folder | Folding function |
returns | Aggregate state |
method EnumerableM<S> scanBack <S, T> (EnumerableM<T> list, S state, Func<S, T, S> folder) Source #
Applies a function to each element of the sequence (from last element to first), threading an accumulator argument through the computation. This function takes the state argument, and applies the function to it and the first element of the sequence. Then, it passes this result into the function along with the second element, and so on. Finally, it returns the list of intermediate results and the final result.
type | S | State type |
type | T | Enumerable item type |
param | list | Enumerable to fold |
param | state | Initial state |
param | folder | Folding function |
returns | Aggregate state |
method EnumerableM<V> zip <T, U, V> (EnumerableM<T> list, EnumerableM<U> other, Func<T, U, V> zipper) Source #
Joins two sequences together either into a single sequence using the join function provided
param | list | First sequence to join |
param | other | Second sequence to join |
param | zipper | Join function |
returns | Joined sequence |
method EnumerableM<(T Left, U Right)> zip <T, U> (EnumerableM<T> list, EnumerableM<U> other) Source #
Joins two sequences together either into an sequence of tuples
param | list | First sequence to join |
param | other | Second sequence to join |
param | zipper | Join function |
returns | Joined sequence of tuples |
method EnumerableM<T> distinct <T> (EnumerableM<T> list) Source #
Return a new sequence with all duplicate values removed
type | T | sequence item type |
param | list | sequence |
returns | A new sequence with all duplicate values removed |
method EnumerableM<T> distinct <EQ, T> (EnumerableM<T> list) Source #
Return a new sequence with all duplicate values removed
type | T | sequence item type |
param | list | sequence |
returns | A new sequence with all duplicate values removed |
method EnumerableM<T> distinct <T, K> (EnumerableM<T> list, Func<T, K> keySelector, Option<Func<K, K, bool>> compare = default) Source #
Return a new sequence with all duplicate values removed
type | T | sequence item type |
param | list | sequence |
returns | A new sequence with all duplicate values removed |
method EnumerableM<T> take <T> (EnumerableM<T> list, int count) Source #
Returns a new sequence with the first 'count' items from the sequence provided
type | T | sequence item type |
param | list | sequence |
param | count | Number of items to take |
returns | A new sequence with the first 'count' items from the sequence provided |
method EnumerableM<T> takeWhile <T> (EnumerableM<T> list, Func<T, bool> pred) Source #
Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't
type | T | sequence item type |
param | list | sequence |
param | count | Number of items to take |
returns | A new sequence with the first items that match the predicate |
method EnumerableM<T> takeWhile <T> (EnumerableM<T> list, Func<T, int, bool> pred) Source #
Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't. An index value is also provided to the predicate function.
type | T | sequence item type |
param | list | sequence |
param | count | Number of items to take |
returns | A new sequence with the first items that match the predicate |
method (EnumerableM<T>, EnumerableM<T>) span <T> (EnumerableM<T> self, Func<T, bool> pred) Source #
Span, applied to a predicate 'pred' and a list, returns a tuple where first element is longest prefix (possibly empty) of elements that satisfy 'pred' and second element is the remainder of the list:
type | T | List element type |
param | self | List |
param | pred | Predicate |
returns | Split list |
Seq.span(Seq(1,2,3,4,1,2,3,4), x => x < 3) == (Seq(1,2), Seq(3,4,1,2,3,4))
Seq.span(Seq(1,2,3), x => x < 9) == (Seq(1,2,3), Seq())
Seq.span(Seq(1,2,3), x => x < 0) == (Seq(), Seq(1,2,3))
class EnumerableM Source #